﻿/*****************************
 * Author: YanNI
 * Create：2018/3/7 17:18:32
 * Email:  admin@ircove.com
 * QQ:     401608886
 * TEl: 13520446271
 ****************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VFPush
{
    /// <summary>
    /// 消息类型
    /// </summary>
    public enum MessageType : byte
    {
        /// <summary>
        /// 控制
        /// </summary>
        CTRL=1,
        /// <summary>
        /// RPC
        /// </summary>
        RPC,
        /// <summary>
        /// 订阅发布
        /// </summary>
        Hub,
        /// <summary>
        /// 心跳
        /// </summary>
        HeartBeat

    }

    /// <summary>
    /// 消息格式
    /// </summary>
    public enum MessageFormat : byte
    {
        Custom=0, JSON, MSGPACK, PROTOBUF
    }

    public class Head
    {
        byte Fix { get; set; }
        /// <summary>
        /// 消息类型
        /// </summary>
        public MessageType type;
        /// <summary>
        /// 消息格式
        /// </summary>
        public MessageFormat Format;
        /// <summary>
        /// 是否包含cmd ID
        /// </summary>
        public bool HasCommandID;
        /// <summary>
        /// 是否包含消息长度
        /// </summary>
        public bool HasMessageLen;
        /// <summary>
        /// 命令ID
        /// </summary>
        public UInt16 CommandID;
        /// <summary>
        /// 消息长度
        /// </summary>
        public UInt16 MessageLen;
    }

    public class Message
    {
         public Head head { get; set; }

         public byte[] Body { get; set; }
    }
}
